<template>
  <div id=push>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="proId"
        label="ID"
        width="180">
      </el-table-column>
      <el-table-column
        prop="proName"
        label="商品名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="newPrice"
        label="现售价">
      </el-table-column>
      <el-table-column
        prop="picUrl"
        label="图片">
        <template slot-scope="scope">
          <img :src="scope.row.picUrl" style="width:50px;height:50px" />
        </template>
      </el-table-column>
      <el-table-column
        prop="proNum"
        label="数量">
      </el-table-column>
      <el-table-column
        prop="sort"
        label="分类">
      </el-table-column>
      <el-table-column
        prop="addTime"
        label="添加时间">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
        <el-button type="danger" @click="outProduct(scope.row.proId)">还原</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
    export default {
      data() {
        return {
          tableData: [],
        }  
      },
      //(文档就绪)
      created:function()
      {
          this.axios
            .get("http://localhost:35043/api/Product/AgainShow"
                
            )
            .then((res)=>{
                this.tableData=res.data.data;
            });
      },
       methods: {
          show(){
            this.axios
            .get("http://localhost:35043/api/Product/AgainShow"
            )
            .then((res)=>{
                this.tableData=res.data.data;
            });
          },
        //加入回收站
        outProduct(a){
          if(!confirm("确认加入还原吗？")){
                return;
            }
          this.axios
            .post("http://localhost:35043/api/Product/DownStatus?id="+a)
              .then((res)=>{
                if(res.data.code ==0)
                  {
                    this.show();
                    alert("还原成功");
                    this.$router.push("/Product");    
                  }else
                  {
                    alert("还原失败");
                    return;
                  }
              })
        }

    }
  }
</script>

